package com.yingxue.lesson.controller;/*
 * @date:2021/6/19 10:45
 * @author: dzj
 **/

import com.yingxue.lesson.entity.SysRole;
import com.yingxue.lesson.service.RoleService;
import com.yingxue.lesson.service.impl.RoleServiceImpl;
import com.yingxue.lesson.utils.DataResult;
import com.yingxue.lesson.vo.req.RoleAddReqVO;
import com.yingxue.lesson.vo.req.RolePageReqVO;
import com.yingxue.lesson.vo.resp.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RequestMapping("/api")
@RestController
@Api(tags = "组织模块-角色管理")
public class RoleController {
    @Autowired
    private RoleServiceImpl roleService;
    @PostMapping("/roles")
    @ApiOperation(value = "分页获取角色信息接口")
    public DataResult<PageVO<SysRole>> pageInfo(@RequestBody RolePageReqVO vo){
        DataResult result= DataResult.success();
        result.setData(roleService.pageInfo(vo));
        return result;
    }
    @PostMapping("/role")
    @ApiOperation(value = "新增角色接口")
    public DataResult<SysRole> addRole(@RequestBody @Valid RoleAddReqVO vo){
        DataResult<SysRole> result=DataResult.success();
        result.setData(roleService.addRole(vo));
        return result;
    }
}
